package com.itcat.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itcat.common.CommonResult;
import com.itcat.mysql.pojo.CmsSubject;
import com.itcat.mysql.pojo.SmsHomeAdvertise;
import com.itcat.mysql.vo.PageResult;
import com.itcat.service.CmsSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Jerry Broker
 * @project_name rainbow-mall
 * @create 2022-04-03 14:45
 */
@RestController
@RequestMapping("/subject")
public class CmsSubjectController {

    @Autowired
    private CmsSubjectService cmsSubjectService;

    /**
     * 获取全部商品专题
     * @return
     */
    @GetMapping("/listAll")
    public CommonResult listAll(){
        List<CmsSubject> list = cmsSubjectService.listAll();
        return CommonResult.success(list);
    }

    /**
     * 分页获取商品专题
     * @return
     */
    @GetMapping("/list")
    public CommonResult list(String keyword,
                             @RequestParam(defaultValue = "1") Integer pageNum,
                             @RequestParam(defaultValue = "10") Integer pageSize){
        Page<CmsSubject> page = cmsSubjectService.list(keyword,pageNum,pageSize);
        return CommonResult.success(page);
    }
}
